package com.teach.controller.photo;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.teach.dto.NewsSearch;
import com.teach.entity.News;
import com.teach.entity.NewsClass;
import com.teach.service.NewsClassService;
import com.teach.service.NewsService;

import lombok.extern.slf4j.Slf4j;


@RestController
@RequestMapping("/photo")
@Slf4j
public class PhotoSkillController {

	@Autowired
	private NewsClassService service;
	
	@Autowired
	private NewsService newsService;
	
	
	@RequestMapping("/a2")
	@ResponseBody
	public List<News> list(@RequestParam(defaultValue = "6") Integer newsClassId, Integer rowMax) {
		log.debug("newsClassId {}", newsClassId);
		log.debug("rowMax {}", rowMax);
		NewsSearch search =  new NewsSearch();
		search.setNewsClassId(newsClassId);
		if(rowMax!= null) {
			search.setRowMax(rowMax);
		}
		return newsService.pageSearchAdmin(search).getList();
	}
	
	
	@RequestMapping("/a1")
	@ResponseBody
	public News get(@RequestParam(required = true) Long newsId) {
		return newsService.get(newsId);
	}
	
}
